﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Twi.COMMON.Core
{
    /*
    * Copyright: ©2013 踏影软件开发工作室【Tyingsoft、Twilight】版权所有
    * Author: xuzhihong
    * Create date: 2010-4-22
    * Description: Encryption Algorithm 加密算法
    * 
    */
    public class ChartDataModel<T>
    {
        public ChartDataModel()
        {
            categories = new List<string>();
            series = new List<ChartDataSeries<T>>();
        }
        /// <summary>
        /// ID标识
        /// </summary>
        public string ID
        {
            get;
            set;
        }

        /// <summary>
        /// 图标类型（Line:折线图 、 Column:柱形图 、 Pie:饼状图）
        /// </summary>
        public string chartType
        {
            get;
            set;
        }

        /// <summary>
        /// "categories":["2013-10-01","2013-10-02"]
        /// </summary>
        public List<string> categories
        {
            get;
            set;
        }

        /// <summary>
        /// "series":[{"name":"Tokyo","data":[49.9,71.5,18]}]
        /// </summary>
        public List<ChartDataSeries<T>> series
        {
            get;
            set;
        }

        public void AddSeries(string name, List<T> data)
        {
            ChartDataSeries<T> item = new ChartDataSeries<T>();
            item.name = name;
            item.data = data;
            series.Add(item);
        }

        /// <summary>
        ///  Pie:饼状图会用到这种数据格式
        /// </summary>
        public List<PieChartDataSeries<T>> pieSeries
        {
            get;
            set;
        }

        public void AddPieSeriesItem(string name,T value)
        {
            if (pieSeries == null)
            {
                pieSeries = new List<PieChartDataSeries<T>>();
            }
            pieSeries.Add(new PieChartDataSeries<T>
            {
                name=name,
                y=value
            });
        }
    }

    public class ChartDataSeries<T>
    {
        public string name
        {
            get;
            set;
        }

        public List<T> data
        {
            get;
            set;
        }
    }

    /// <summary>
    /// 饼状图的数据格式
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class PieChartDataSeries<T>
    {
        public string name
        {
            get;
            set;
        }
        public T y
        {
            get;
            set;
        }
    }
}
